﻿#include <ElementPreviewCanvas.h>
#include <QMouseEvent>
ElementPreviewCanvas::ElementPreviewCanvas(QObject *parent)
    : QGraphicsScene{parent}
{
    //installEventFilter(this);
}

ElementPreviewCanvas::~ElementPreviewCanvas()
{

}
static int n=0;
bool ElementPreviewCanvas::eventFilter(QObject *obj, QEvent *event) {
    if (obj == this && event->type() == QEvent::MouseButtonRelease) {
        qDebug()<<n++;
        QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
        if (mouseEvent->button() == Qt::LeftButton) {
            emit clicked();
        }
    }
    return QGraphicsScene::eventFilter(obj, event);
}
